package com.twt.recruit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.twt.recruit.entity.Application;
import com.twt.recruit.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ApplicationMapper extends BaseMapper<Application> {
    @Select("select count(*) from application where project_id = #{projectId}")
    Integer getApplicationNum(Integer projectId);

    @Select("select application_id from application where project_id = #{projectId}")
    List<Integer> listApplicationIdsByProjectId(Integer projectId);

    @Select("select * from application where application_uid = #{uid}")
    List<Application> listApplicationsByUid(String uid);


    @Select("select group_name from group_info where group_id in (select application_info.group_id from application_info where application_id = #{applicationId})")
    List<String> listGroupNamesByApplicationId(Integer applicationId);


    @Select("select time_section from time where application_id = #{applicationId}")
    List<String> listTimesByApplicationId(Integer applicationId);

    @Select("select * from category where group_id = #{groupId} and category_id in (select category_info.category_id from category_info where application_id = #{applicationId})")
    List<Category> listCategoriesByApplicationId(Integer applicationId, Integer groupId);


    @Select("select category_name from category where group_id = #{groupId} and category_id in (select category_info.category_id from category_info where application_id = #{applicationId})")
    List<String> listCategoryNamesByApplicationId(Integer applicationId, Integer groupId);

    @Delete("delete from application where project_id = #{projectId}")
    void delApplicationByProjectId(Integer projectId);
}
